package com.example.music.utils;

import com.google.common.collect.Maps;

import java.util.Map;

public class UserUtil {
    private static ThreadLocal<Map<String, String>> threadLocal = new ThreadLocal<>();
    private static Map<String, String> getMap(){
        Map<String, String> map = threadLocal.get();
        if (map == null){
            map = Maps.newHashMap();
            threadLocal.set(map);
        }
        return map;
    }

    public static String getUserId(){
        return getMap().get("user_id");
    }
    public static void setUserId(String userId){
        getMap().put("user_id",String.valueOf(userId));
    }
    public static String getUserName(){
        return getMap().get("user_name");
    }
    public static void setUserName(String userName){
        getMap().put("user_name",String.valueOf(userName));
    }
}
